# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=sigal
pkgver=2.3
pkgrel=2
pkgdesc="Yet another simple static gallery generator"
arch=(any)
url="http://sigal.saimon.org/en/latest/"
license=(MIT)
depends=(
  ffmpeg
  python
  python-blinker
  python-click
  python-jinja
  python-markdown
  python-natsort
  python-pillow
  python-pilkit
)
makedepends=(
  python-build
  python-installer
  python-setuptools-scm
  python-toml
  python-wheel
)
checkdepends=(
  python-boto
  python-brotli
  python-cryptography
  python-feedgenerator
  python-pytest
  python-zopfli
)
optdepends=(
  'python-boto: upload to S3 plugin'
  'python-brotli: compress assets plugin'
  'python-cryptography: encrypt plugin'
  'python-feedgenerator: feed plugin'
  'python-zopfli: compress assets plugin'
)
source=(https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz)
sha512sums=('e7eafc3c624497f19fdc9eb96fce67789db027b3c34c28eadcc162dd176a2462e101f16ffd54e08ee85baf1a9d264c5657e6cd264c40e155def4eee539242597')
b2sums=('869665335c57e06b23b7daecc8d32aa1441ce9498ac480f0edebb705020fd16232c0d5e1f88b94d4ae92fc4f126ea43eec6f4cf61cbaeb3e86a470b6fdbcdae0')

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local pytest_options=(
    # disable failing tests: https://github.com/saimn/sigal/issues/489
    --deselect tests/test_gallery.py::test_gallery_max_img_pixels
    --deselect tests/test_video.py::test_generate_video_fit_height[mp4]
    --deselect tests/test_video.py::test_generate_video_fit_width[mp4]
    --deselect tests/test_video.py::test_generate_video_dont_enlarge[mp4]
  )

  cd $pkgname-$pkgver
  pytest -vv "${pytest_options[@]}"
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {AUTHORS,{CONTRIBUTING,README}.rst} -t "$pkgdir/usr/share/doc/$pkgname/"
}
